;Buckna's Steel smither
;Varrock EastSide...

SetVarNum(%MoveFail,0)
SetVarNum(%runs,0)
SetVarNum(%banks,0)
SetSkipDestTime(155)
SetRetryDestTime(10)
SetCheatDestTime(20)

GoTo(@BackToBank)


@Sleeping:
AddVarNum(%runs,1)
;DebugVar(%runs)
GoToIfVarAboveNum(@GetSomeSleep,%runs,8)
GoToIfVarEqualNum(@GetSomeSleep,%runs,8)

SetVarFatigue(%v)
DebugVar(%v)
GoToIfVarAboveNum(@GetSomeSleep,%v,600)


@Banking:
ResetQuestMenu()
SetVarNum(%banks,0)
ResetLastServerMessage()
SetVarsRandomNPCIn(%x,%y,%ID,106,510,98,515,95)
GoToIfVarEqualNum(@Dead,%ID,-1)
ActionVarVar(%x,%y)
TalkToNPCVar(%ID)
ResetQuestMenu()
WaitForQuestMenu(15)
GoToIfLastServerMessageIs(@Banking,"Banker is busy at the moment")
GoToIfQuestMenu(@ContactWithBanker)
ResetQuestMenu()
WaitForQuestMenu(15)
GoToIfLastServerMessageIs(@Banking,"Banker is busy at the moment")
GoToIfQuestMenu(@ContactWithBanker)
ResetQuestMenu()
WaitForQuestMenu(15)
GoToIfLastServerMessageIs(@Banking,"Banker is busy at the moment")
GoToIfQuestMenu(@ContactWithBanker)
GoTo(@Banking)

@ContactWithBanker:
Answer(0)
WaitForBankWindow(50)
Wait(5)
DepositEverything()
Wait(10)
ResetLastServerMessage()
SetVarNum(%withdraws,9)
@WithdrawStuff:
AddVarNum(%banks,1)
Withdraw(171,1)
Withdraw(171,1)
Withdraw(171,1)
Wait(2)
AddVarNum(%withdraws,-1)
GoToIfVarAboveNum(@WithdrawStuff,%withdraws,0)
GoToIfVarAboveNum(@Banking,%banks,30)
-GoToIfLastServerMessageIsNot(@WithdrawStuff,"You don't have room to hold that object!")
Wait(30)
CloseBank()
Wait(10)
GoToIfCountInInventoryEqual(@Banking,0,171)
GoTo(@MoveToSmith)

@MoveToSmith:
GoToIfCoordsIn(@InBank,106,510,98,515)
GoToIfCoordsIn(@OpenDoor,117,506,117,506)
GoToIfCoordsIn(@OnTheWay,98,509,119,506)
GoToIfCoordsIn(@DoSmithing,119,505,113,498)
AddVarNum(%MoveFail,1)
GoToIfVarEqualNum(@Dead,%MoveFail,60)
Wait(10)
GoTo(@MoveToSmith)


@BackToBank:
GoToIfCoordsIn(@OpenDoorAgain,117,505,117,505)
GoToIfCoordsIn(@OutOfAnvils,119,505,113,498)
GoToIfCoordsIn(@OnTheWayBack,98,509,119,506)
GoToIfCoordsIn(@Sleeping,106,510,98,515)
AddVarNum(%MoveFail,1)
GoToIfVarEqualNum(@Dead,%MoveFail,60)
Wait(10)
GoTo(@BackToBank)

@InBank:
MoveToRandomly(103,510,102,510)
Wait(1)
;Action(103,510)
;AtObject(102,509)
Wait(2)
MoveTo(102,509)
GoTo(@MoveToSmith)

@OpenDoor:
Wait(2)
Action(117,506)
OpenDoor(117,506,0)
Wait(1)
MoveTo(117,505)
GoTo(@MoveToSmith)

@OnTheWay:
MoveTo(103,508)
MoveTo(117,508)
MoveToNoWait(117,503)
Wait(30)
GoTo(@MoveToSmith)

@DoSmithing:
Action(118,502)
AtObjectWithItemByID(118,501,171)
WaitForQuestMenu(50)
Answer(1)
WaitForQuestMenu(50)
Answer(2)
WaitForQuestMenu(50)
Answer(1)
Wait(20)
GoToIfCountInInventoryGreater(@DoSmithing,4,171)
GoTo(@BackToBank)

@OutOfAnvils:
MoveTo(117,505)
MoveToNoWait(117,506)
Wait(15)
GoTo(@BackToBank)

@OpenDoorAgain:
Wait(1)
Action(117,505)
OpenDoor(117,506,0)
Wait(2)
MoveTo(117,506)
GoTo(@BackToBank)

@OnTheWayBack:
-MoveTo(102,506)
MoveToRandomly(102,509,103,509)
Wait(2)
-Action(103,509)
-AtObject(102,509)
Wait(1)
MoveToNoWait(102,512)
Wait(30)
GoTo(@BackToBank)

@GetSomeSleep:
SetVarNum(%runs,0)
UseItem(0)
ResetLastServerMessage()
SetVarNum(%secs,0)
@JustWait:
Wait(10)
AddVarNum(%secs,1)
GoToIfVarAboveNum(@GetSomeSleep,%secs,70)
GoToIfLastServerMessageIsNot(@JustWait,"You wake up - feeling refreshed")
SetVarNum(%secs,0)
GoTo(@Sleeping)

@Dead:
SaveScreenshot()
Wait(2)
StopAndLogOut()
